<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
 
<html>
  <head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
    <link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
  </head>
  
  <script type="text/javascript">  
   $(function(){ 
	    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
	    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
	    loadTab();    
  });
  
  //加载表
  function loadTab(){ 
      $("#myTab").jqGrid({      
		    url:'<s:url value="/jydz"/>/findHttkMobGrid',   
		    datatype: 'json',
		    mtype: 'post',         
		   	colNames:['操作','模板名称','申请时间','模板状态'],
		   	colModel:[ 
		   	    {name:'caoz',index:'mobbm',width:100,align:"center"},  		
		   		{name:'mobmc',index:'mobmc', width:400},
		   		{name:'gengxsj',index:'gengxsj', width:200},   				
		   		{name:'mobzt',index:'mobzt', width:150, sortable:false}		
		   	],
		   
		    jsonReader: {
		           repeatitems : false, 
		           id: 'mobbm'
		         },   
		    height:300, 	
		   	rowNum:10,
		   	rowList:[10,30,50],     	
		   	pager: '#pager13',
		   	rownumbers: true,   	 
		    viewrecords: true,
		    multiselect: true, 
		    sortorder: 'desc', 
		    caption: "模板列表",
			gridComplete:function()
				{ //在此事件中循环为每一行添加修改和删除链接 	
					var ids=$("#myTab").jqGrid('getDataIDs'); 
					//alert(ids);
					for(var j=0; j<ids.length; j++)
					{		
					     id=ids[j];		    
						 caoz="<a href='#' style='color:#f60' onclick='verify("+ id +")'>编辑</a>&nbsp;|&nbsp;<a href='#' style='color:#f60' onclick='display("+ id +");'>查看 </a>";
						 $("#myTab").jqGrid('setRowData',id, { caoz: caoz }); 
						
					}
				}		
  });
  }
  
	//重置
	function reset(){
	    $('#list_search  input[type=text]').val('');
		//$('#list_search select').val('-1');
	 }
	
	// 查询
	function search(){ 
	  var formdata = $("#form1").serialize(); 
	  $("#myTab").jqGrid('setGridParam',{   
	                          url:'<s:url value="/jydz"/>/findHttkMobGrid?'+formdata,
							  mtype:'post',
							  page:1}).trigger("reloadGrid");  
	}
	
	 //删除
	function remove() {	
		var bms = $("#myTab").jqGrid('getGridParam','selarrrow');
		var url = "<s:url value="/jydz"/>/removeDzHttk?bms="+bms;
		$( "#dialog-confirm" ).dialog({
				resizable: false,
				height:140,
				modal: true,
				buttons: {
					"确认": function() {
						$.post(url, function(data) {
							var obj =	eval('(' + data + ')');
							if(obj.success==true){
							        alert(obj.msg);
							        location.href ="<s:url value="/jydz"/>/findTiaok";
							 }else{
							         alert(obj.msg);
							       }
	                   });
	                   $( this ).dialog( "close" ); 
					},
					"返回": function() {
						$( this ).dialog( "close" );
					}
				}
			});
	}
	
	//查看
	function display(id) { 
	    /* //alert(id);
	    if(id.id!=undefined){
	    window.location.href='<s:url value="/jydz"/>/displayHttk?mobbm='+id.id; 
	    }else{
	    var mobbm = id.item(1).cells.item(1).innerHTML;
		window.location.href='<s:url value="/jydz"/>/displayHttk?mobbm='+ mobbm;
	    }	 */   
	    window.location.href='<s:url value="/jydz"/>/displayHttk?mobbm='+ id;
	}
	
	//修改
	function verify(id) { //单击修改链接的操作
	/* //alert(id); 
	if(id.id!=undefined){
	window.location.href='<s:url value="/jydz"/>/editHttk?mobbm='+ id.id;
	}else{
	var mobbm = id.item(1).cells.item(1).innerHTML;
		window.location.href='<s:url value="/jydz"/>/editHttk?mobbm='+ mobbm;
	} */
	window.location.href='<s:url value="/jydz"/>/editHttk?mobbm='+ id;
	}

    //新增合同条款
	function addTiaok()
	{
	    window.location.href='addTiaok',target='mainFrame';
	}
</script>  
<body>  
<div class="container">
 <div class="containerbox">
  <div class="btn-bar"> 
    <a id="xinz" href="#" class="btn" onclick= "addTiaok();"><img src="<s:url value="/resources"/>/img/ico_23.gif" /><span>新增</span></a> 
    <a id="shanc" href="#" class="btn" onclick="remove();"><img src="<s:url value="/resources"/>/img/ico_25.gif" /><span>删除</span></a>
   </div>
 <div class="search mt10" id="list_search">
<form id="form1" method="post">
<table  class="search-table"  style="width:90%"  cellpadding="0" cellspacing="0" border="0"> 
        <tr>
        	<td> 
            	模板名称: 
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="aa" /> 
            </td>
           <td>
            	申请时间:
            </td>
            <td>
            	<input id="datepicker" type="text" class="form-textbox" style="width: 93px;" name="bb" /> -- <input id="datepicker1" type="text" class="form-textbox" style="width: 93px;" name="cc" />
            </td>
        </tr>
        <tr>
            <td>
                 <input  type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
                 <input  type="reset" class="form-button-reset form-button" value="重置" />
            </td>
        </tr>
  </table>
  </form>
    </div>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0"></table>  
   <div id="pager13" class="scroll"></div>  
   <div id="message" class="scroll"></div> 
</div> 
</div>
<div id="dialog-confirm" title="是否确认删除？"></div>
</body>
</html>
